package me.jessyan.armscomponent.app.mvp.ui.activity.learn;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import butterknife.BindView;
import butterknife.OnClick;
import me.jessyan.armscomponent.commonsdk.core.RouterHub;
import me.jessyan.armscomponent.app.R;
import me.jessyan.armscomponent.app.di.component.DaggerPlanDetailComponent;
import me.jessyan.armscomponent.app.mvp.contract.learn.PlanDetailContract;
import me.jessyan.armscomponent.app.mvp.presenter.learn.PlanDetailPresenter;

import static com.jess.arms.utils.Preconditions.checkNotNull;


/**
 * <p> 我的学习计划-详情页面-简介 113
 * Author: Taozebi
 * Date: 08/16/2021 18:15
 * Description: describe of this class
 */

@Route(path = RouterHub.LEARNING_PLANDETAILACTIVITY)
public class PlanDetailActivity extends BaseActivity<PlanDetailPresenter> implements PlanDetailContract.View {
    @BindView(R.id.plan_detail_intro)
    TextView plan_detail_intro;
    @BindView(R.id.plan_detail_course)
    TextView plan_detail_course;

    @BindView(R.id.learning_plan_detail_course)
    LinearLayout learning_plan_detail_course;

    @BindView(R.id.learning_plan_detail_intro)
    LinearLayout learning_plan_detail_intro;

    @OnClick({R.id.plan_detail_intro, R.id.plan_detail_course})
    void onClick(View view) {
        if (view.getId() == R.id.plan_detail_course) {
            learning_plan_detail_intro.setVisibility(View.GONE);
            learning_plan_detail_course.setVisibility(View.VISIBLE);
            //修改选中文字的颜色
            plan_detail_course.setTextColor(getResources().getColor(R.color.black_light));
            plan_detail_intro.setTextColor(getResources().getColor(R.color.sub_title_grey));

        } else if (view.getId() == R.id.plan_detail_intro) {
            learning_plan_detail_intro.setVisibility(View.VISIBLE);
            learning_plan_detail_course.setVisibility(View.GONE);
            //修改选中文字的颜色
            plan_detail_intro.setTextColor(getResources().getColor(R.color.black_light));
            plan_detail_course.setTextColor(getResources().getColor(R.color.sub_title_grey));

        }
    }

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerPlanDetailComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .view(this)
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.learning_activity_plan_detail; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {

    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }
}
